<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <script type="text/javascript" src="../static/lib/html5shiv.js"></script>
    <script type="text/javascript" src="../static/lib/respond.min.js"></script>
    <script type="text/javascript" src="../static/lib/jquery/1.9.1/jquery.min.js"></script>
    <link rel="stylesheet" href="../static/h-ui/css/H-ui.css" />
    <link rel="stylesheet" href="../static/css/company.css" />
    <meta charset="UTF-8">
    <title>Add Company Information</title>
</head>
<body>
<article class="page-container">
    <div class="panel panel-default">

        <div class="panel-header">Add Company Information</div>
        <div class="panel-body">
            <form action="" method="post" class="form form-horizontal" id="form-company-add">
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>公司名称（中文）：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="" placeholder="" id="nameCN" name="nameCN">
                    </div>

                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>公司名称（英文）：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="" placeholder="" id="nameEN" name="nameEN">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>品牌商认证类型：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="" placeholder="" id="GMCtype" name="GMCtype">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>证书地址：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="" placeholder="url:" id="comUrl" name="comUrl">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3">公司简介：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <textarea name="info" cols="" rows="" class="textarea" placeholder="请输入"></textarea>
                        <p class="textarea-numberbar"><em class="textarea-length">0</em>/<am>100</am></p>
                    </div>
                </div>
                <div class="row cl">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    </div>
                </div>
            </form>
        </div>
    </div>
</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../static/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="../static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
    function getComInfo(){
        var nameCn = $("#nameCN").val();
        var nameEn = $("#nameEN").val();
        var GMCtype = $("#GMCtype").val();
        var comURL = $("#comUrl").val();
        var info = document.getElementsByName("info")[0].value;
        var comInfo = {
            'nameCn':nameCn,
            'nameEn':nameEn,
            'info':info,
            'rType':GMCtype,
            'rUrl':comURL
        }
        console.log(comInfo)
        return comInfo;
    }
    $(function(){

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-company-add").validate({
            rules:{
                nameCn:{
                    required:true,
                    minlength:2,
                    maxlength:30
                },nameEn:{
                    required:true,
                    minlength:2,
                    maxlength:100
                },GMCtype:{
                    required:true,
                    minlength:2,
                    maxlength:30
                },comUrl:{
                    required:true,
                    minlength:2,
                    maxlength:100
                },info:{
                    maxlength:100
                },

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var comInfo=getComInfo();
                console.log("提交表单：",comInfo);
                var url="/mvo/addcom";
                $.ajax({
                    type:'POST',
                    url:url,
                    data:JSON.stringify(comInfo),
                    contentType:"application/json",
                    dataType:'json',
                    success:function () {
                        console.log("新增信息成功")
                        window.location.href = "/mvo/getmvoinfo";
                    }
                });
            }
        });
    });

</script>
</body>
</html>

